package com.ruoyi.purchase.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.purchase.domain.PlanOrderLink;
import com.ruoyi.purchase.service.IPlanOrderLinkService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * systemController
 * 
 * @author kevinness
 * @date 2025-02-10
 */
@RestController
@RequestMapping("/plan/order/link")
public class PlanOrderLinkController extends BaseController
{
    @Autowired
    private IPlanOrderLinkService planOrderLinkService;

    /**
     * 查询system列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PlanOrderLink planOrderLink)
    {
        startPage();
        List<PlanOrderLink> list = planOrderLinkService.selectPlanOrderLinkList(planOrderLink);
        return getDataTable(list);
    }

    /**
     * 导出system列表
     */
    @Log(title = "system", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PlanOrderLink planOrderLink)
    {
        List<PlanOrderLink> list = planOrderLinkService.selectPlanOrderLinkList(planOrderLink);
        ExcelUtil<PlanOrderLink> util = new ExcelUtil<PlanOrderLink>(PlanOrderLink.class);
        util.exportExcel(response, list, "system数据");
    }

    /**
     * 获取system详细信息
     */
    @GetMapping(value = "/{planNo}")
    public AjaxResult getInfo(@PathVariable("planNo") String planNo)
    {
        return success(planOrderLinkService.selectPlanOrderLinkByPlanNo(planNo));
    }

    /**
     * 新增system
     */
    @Log(title = "system", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PlanOrderLink planOrderLink)
    {
        return toAjax(planOrderLinkService.insertPlanOrderLink(planOrderLink));
    }

    /**
     * 修改system
     */
    @Log(title = "system", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PlanOrderLink planOrderLink)
    {
        return toAjax(planOrderLinkService.updatePlanOrderLink(planOrderLink));
    }

    /**
     * 删除system
     */
    @Log(title = "system", businessType = BusinessType.DELETE)
	@DeleteMapping("/{planNos}")
    public AjaxResult remove(@PathVariable String[] planNos)
    {
        return toAjax(planOrderLinkService.deletePlanOrderLinkByPlanNos(planNos));
    }

    /**
     * 批量插入
     */
    @PostMapping("/addList")
    public AjaxResult addList(@RequestBody List<PlanOrderLink> list){
        return toAjax(planOrderLinkService.insertPlanOrderList(list));
    }
}
